#include "PixelHelper.h"



QRgb PixelHelper::alphaBlend (QRgb upper, QRgb lower)
{
  // Blend two pixels, transform pixel is above
  float upperAlpha = (float)qAlpha (upper) / 255;
  float lowerAlpha = (float)qAlpha (lower) / 255;
  lowerAlpha *= (1.0 - upperAlpha);

  float previewR = upperAlpha * qRed (upper) + lowerAlpha * qRed (lower);
  float previewG = upperAlpha * qGreen (upper) + lowerAlpha * qGreen (lower);
  float previewB = upperAlpha * qBlue (upper) + lowerAlpha * qBlue (lower);
  float previewA = (upperAlpha + lowerAlpha) * 255;

  return qRgba (previewR, previewG, previewB, previewA);

}
